﻿using AutoMapper;
using Casbin.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;

namespace Web.Controllers
{
    [Route("")]
    [AppRule("ping", nameof(PingController))]
    [AppActionRule("ping", nameof(ping))]
    [AppActionRule("ping1", nameof(ping1))]
    //[AppActionRule(AppActionRulesHelp.get, nameof(AppActionRulesHelp.get))]
    //[AppActionRule(AppActionRulesHelp.add, nameof(AppActionRulesHelp.add))]
    //[AppActionRule(AppActionRulesHelp.update, nameof(AppActionRulesHelp.update))]
    public class PingController : AppController
    {
        private readonly ILogger<PingController> _logger;
        //private readonly RegisterBase<aa> _a;
        public PingController(IMapper mapper,
            ILogger<PingController> logger) : base(mapper)
        {
            _logger = logger;
        }

        /// <summary>
        /// ping
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpGet]
        public string ping()
        {
            Log.Information("pong");
            return "pong 无权限";

        }

        [HttpGet]
        [CasbinAuthorize(nameof(PingController), nameof(AppActionRulesHelp.get))]
        public string ping1()
        {
            return "pong 有权限";
        }
    }
}
